import { http } from "@/utils/http";
import type { HttpResult } from "@/utils/http/types";

export function queryEntryTable(params) {
  return http.request<HttpResult>("get", "/admin/dictentry/get/table", {
    params: params
  });
}

export function queryEntryList(params) {
  return http.request<HttpResult>("get", "/admin/dictentry/get/list", {
    params: params
  });
}

export function queryDictTree(params) {
  return http.request<HttpResult>("get", "/admin/dict/get/tree", {
    params: params
  });
}

export function queryDictList(params) {
  return http.request<HttpResult>("get", "/admin/dict/get/list", {
    params: params
  });
}

export function addDict(params) {
  return http.request<HttpResult>("post", "/admin/dict/insert", {
    data: params
  });
}

export function updateDict(params) {
  return http.request<HttpResult>("post", "/admin/dict/update", {
    data: params
  });
}

export function deleteDict(ids) {
  return http.request<HttpResult>("post", `/admin/dict/delete/${ids}`);
}

export function addDictEntry(params) {
  return http.request<HttpResult>("post", "/admin/dictentry/insert", {
    data: params
  });
}

export function updateDictEntry(params) {
  return http.request<HttpResult>("post", "/admin/dictentry/update", {
    data: params
  });
}

export function deleteDictEntry(ids) {
  console.log(ids);
  return http.request<HttpResult>("delete", `/admin/dictentry/delete/${ids}`);
}

export function refreshDictEntry(params) {
  return http.request<HttpResult>("get", "/admin/dictentry/refresh", {
    params: params
  });
}

export function validDictCode(data) {
  return http.request<HttpResult>("get", "/admin/dict/get/exists", {
    params: data
  });
}
